<?php

class VideosController extends BaseController {
        
    public function indexAction($requestData) {
    	$videoTitle = isset($requestData['arg0']) ? $requestData['arg0'] : "";
    	$sports = array("cycling", "running", "mountain-climbing", "swimming", "adventure-racing", "mountain-biking", "ironman");
    	if($videoTitle != "" && !in_array($videoTitle, $sports)) {
    		$video = pk_video::get(seourl($videoTitle), "title");
    		if($video->id > 0) {
    			$this->data['video'] = $video;
    		}
    	}
    	$sportStr = isset($requestData['arg0']) ? $requestData['arg0'] : "";
		$featured = pk_sport::getFeaturedSport($sportStr);
    	$sport = $featured->id;
    	if(isset($this->data['video'])) {
    		$sports = explode('|', $this->data['video']->sports);
    		foreach($sports as $_sport) {
    			if(is_numeric($_sport)) {
    				$sport = $_sport;
    				break;
    			}
    		}
    	}
    	$this->data['featuredTitle'] = $featured->name;
    	
    	$this->data['videos'] = pk_video::getVideos($sport, 16);
    	
    	$this->data['page'] = 'videos';
    	
    	$this->data['pageTitle'] = isset($this->data['video']) 
							    	? $this->data['video']->title 
							    	: $featured->name . " Videos";
    }

}

?>